package com.orange.stat.controller;


import com.orange.commonutils.result.Result;
import com.orange.stat.service.DailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author orange
 * @since 2021-12-29
 */
@RestController
@CrossOrigin
@RequestMapping("/stat/daily")
public class DailyController {

    @Autowired
    private DailyService dailyService;

    //统计指定日期注册人数
    @PostMapping("/createStatisticsByDay/{day}")
    public Result createStatisticsByDay(@PathVariable String day) {
        dailyService.createStatisticsByDay(day);
        return Result.ok();
    }

    //图表显示，返回两部分数据，日期json数组，数量json数组
    @GetMapping("/showData/{type}/{begin}/{end}")
    public Result showData(@PathVariable("type") String type,
                           @PathVariable("begin") String begin,
                           @PathVariable("end") String end) {

        Map<String, Object> map = dailyService.getShowData(type, begin, end);
        return Result.ok().data(map);
    }
}

